﻿using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using XLua;
public class LuaCallDelegate : MonoBehaviour
{
    public delegate double LuaMax(double a, double b);

    private void Start()
    {
        LuaEnv luaEnv = new LuaEnv();

        var max = luaEnv.Global.GetInPath<LuaMax>("math.max");
        Debug.Log("max:"+max(12,32));
        max = null;

        luaEnv.DoString("require 'LuaCallDelegate'");
        luaEnv.Dispose();
    }

    public void SetData(GameObject trans)
    {
        Debug.Log("lua call C#");
        trans.name = "update by lua";
        trans.transform.localPosition = new Vector3(100, 100, 0);
    }

    [LuaCallCSharp]
    public void LuaCallCSharpFun1()
    {
        Debug.Log("LuaCallCSharpFun1");
    }

    public void LuaCallCSharpFun2()
    {
        Debug.Log("LuaCallCSharpFun2");
    }
}


